<div class="panel panel-default panel-intro">
    <div class="panel-heading">
        <h3 class="panel-title">库存预警</h3>
        <div class="panel-actions">
            <a href="{:url('index')}" class="btn btn-default">返回物料列表</a>
        </div>
    </div>
    <div class="panel-body">
        <div class="alert alert-warning">
            <h4><i class="icon fa fa-warning"></i> 库存预警提醒</h4>
            <p>以下物料库存不足，请及时补充库存：</p>
        </div>
        
        <div class="table-responsive">
            <table class="table table-bordered table-striped">
                <thead>
                    <tr>
                        <th width="5%">#</th>
                        <th width="15%">物料名称</th>
                        <th width="10%">物料编码</th>
                        <th width="10%">分类</th>
                        <th width="10%">规格型号</th>
                        <th width="8%">单位</th>
                        <th width="10%">当前库存</th>
                        <th width="10%">最低库存</th>
                        <th width="10%">安全库存</th>
                        <th width="12%">库存状态</th>
                    </tr>
                </thead>
                <tbody>
                    {foreach name="list" item="vo" key="k"}
                    <tr class="danger">
                        <td>{$k+1}</td>
                        <td>
                            <strong>{$vo.name}</strong>
                            {if condition="$vo.brand"}
                            <br><small class="text-muted">品牌：{$vo.brand}</small>
                            {/if}
                        </td>
                        <td>{$vo.code}</td>
                        <td>{$vo.category}</td>
                        <td>{$vo.spec}</td>
                        <td>{$vo.unit}</td>
                        <td>
                            <span class="text-danger"><strong>{$vo.stock}</strong></span>
                        </td>
                        <td>{$vo.min_stock}</td>
                        <td>{$vo.safety_stock}</td>
                        <td>
                            {if condition="$vo.stock <= 0"}
                                <span class="label label-danger">缺货</span>
                            {elseif condition="$vo.stock < $vo.min_stock"}
                                <span class="label label-warning">库存不足</span>
                            {elseif condition="$vo.stock < $vo.safety_stock"}
                                <span class="label label-info">低于安全库存</span>
                            {else}
                                <span class="label label-success">正常</span>
                            {/if}
                        </td>
                    </tr>
                    {/foreach}
                </tbody>
            </table>
        </div>
        
        {if condition="empty($list)"}
        <div class="alert alert-success">
            <h4><i class="icon fa fa-check"></i> 库存正常</h4>
            <p>所有物料库存充足，无需预警！</p>
        </div>
        {/if}
        
        <div class="row">
            <div class="col-md-12">
                <div class="alert alert-info">
                    <h4><i class="icon fa fa-info"></i> 库存管理建议</h4>
                    <ul>
                        <li><strong>缺货物料</strong>：需要立即采购，建议联系供应商紧急补货</li>
                        <li><strong>库存不足</strong>：建议尽快采购，避免影响生产</li>
                        <li><strong>低于安全库存</strong>：建议提前采购，确保生产连续性</li>
                        <li><strong>采购建议</strong>：根据物料采购提前期，提前安排采购计划</li>
                    </ul>
                </div>
            </div>
        </div>
    </div>
</div>
